package com.atguigu.tingshu.user.client;

import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.user.VipServiceConfig;
import com.atguigu.tingshu.user.client.impl.UserDegradeFeignClient;
import com.atguigu.tingshu.vo.user.UserInfoVo;
import com.atguigu.tingshu.vo.user.UserPaidRecordVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 用户模块远程调用API接口
 * </p>
 *
 * @author atguigu
 */
@FeignClient(value = "service-user", path = "/api/user", fallback = UserDegradeFeignClient.class)
public interface UserFeignClient {


    /**
     * 根据用户ID查询用户信息
     *
     * @param userId
     * @return
     */
    @GetMapping("/userInfo/getUserInfoVo/{userId}")
    public Result<UserInfoVo> getUserInfoVo(@PathVariable Long userId);

    /**
     * 判断提交的声音id购买状态
     *
     * @param userId                         用户id
     * @param albumId                        专辑id
     * @param needCheckPayStatussTrackIdList 需要检查的购买状态的声音id列表
     * @return {
     * "声音id":购买状态
     * "声音id":购买状态
     * "声音id":购买状态
     * }
     * 1：已购买 0：未购买
     */
    @PostMapping("/userInfo/userIsPaidTrack/{userId}/{albumId}")
    public Result<Map<Long, Integer>> userIsPaidTrack(
            @PathVariable Long userId,
            @PathVariable Long albumId,
            @RequestBody List<Long> needCheckPayStatussTrackIdList
    );

    /**
     * 根据套餐id查询套餐信息
     *
     * @param id
     * @return
     */
    @GetMapping("/vipServiceConfig/getVipServiceConfig/{id}")
    public Result<VipServiceConfig> getVIpServiceConfigById(@PathVariable Long id);

    /**
     * 判断当前用户是否购买了指定专辑
     *
     * @param albumId
     * @return
     */
    @GetMapping("/userInfo/isPaidAlbum/{albumId}")
    public Result<Boolean> isPaidAlbum(@PathVariable Long albumId);

    /**
     * 查询当前用户指定专辑下已购声音列表
     *
     * @param userId
     * @param albumId
     * @return
     */
    @GetMapping("/userInfo/findUserPaidTrackList/{albumId}")
    public Result<List<Long>> findUserPaidTrackIdList(Long userId, @PathVariable Long albumId);

    /**
     * 用户付款成功后，给用户进行虚拟物品的发货
     * 这里不能加@GuiguLogin，
     * 因为用户付款方式如果是微信支付，微信支付回调之后不会带上用户信息
     *
     * @param userPaidRecordVo
     * @return
     */
    //@GuiguLogin
    @PostMapping("/userInfo/savePaidRecord")
    public Result savePaidRecord(@RequestBody UserPaidRecordVo userPaidRecordVo);
}
